﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>test jquery</title>
        @Scripts.Render("~/bundles/jquery")
        <script type="text/javascript" >
            $(document).ready(function(){
                $('#idBtn1').click(function(){
                    // document.domain = "localhost:88";
                    var rd = '?random=' + Math.random();
                    var ard = '&random=' + Math.random();
                    var pages = [
                        // 'http://192.168.0.26:28102/Bonus/YJInfo/Index?sf=&userno=1712002&username=吴肖均',
                    //  'http://localhost:88/Bonus/ProductBusinessSummary/Index'
                     //,
                    //'errorPage1.html',
                    //'errorPage2.html'

                    '/Bonus/YJInfo/Index?userno=1712002&token=f61cc7e3a1f273a6ab2bef4b2f81557e',
                    '/Bonus/YJProvinceNet/Index?sf=04&userno=1712002&token=2fa8d35cc0528177030c82c2dbf157cc',
                    '/Bonus/ProductBusinessSummary/Index?userno=1712002&token=f61cc7e3a1f273a6ab2bef4b2f81557e',
                    '/Bonus/FinancialDailyReport/Index?sf=04&userno=1712002&token=2fa8d35cc0528177030c82c2dbf157cc',
                    '/Bonus/FinancialDailyReport/Index?sf=04&authority=Default&userno=1712002&token=2fa8d35cc0528177030c82c2dbf157cc',
                    //////'/Bonus/FinancialDailyReport/Index?authority=Import,Export',
                    '/Bonus/RegionYearOnYear/Index?sf=04&userno=1712002&token=2fa8d35cc0528177030c82c2dbf157cc',
                    '/Bonus/SingleShopDetail/Index?sf=04&userno=1712002&token=2fa8d35cc0528177030c82c2dbf157cc',
                    '/Bonus/AchievementImproveNew/Index?userno=1712002&token=f61cc7e3a1f273a6ab2bef4b2f81557e',
                    '/Bonus/PromotionRePurchase/Index?sf=04&userno=1712002&token=2fa8d35cc0528177030c82c2dbf157cc'//,
                    //'/Sale/YahuoAnalyseSelect/CorpList'//此功能要登陆的
                    ];

                    // var pages=['errorPage1.html'];
                    var errorPages = [];
                    var _pfJsError=false;
                    window.SetPfJsError=function(url){
                        _pfJsError = true;
                        errorPages.push(url);
                        // document._pfJsError=true;
                        if (loadedCount === pages.length) {
                            if (errorPages.length > 0) {
                                console.info(errorPages);
                                alert('以下页面有js错误:' + JSON.stringify(errorPages));
                            } else {
                                alert('恭喜！全部页面无js错误');
                            }
                        }
                    };
                    var ifrs=[];
                    var $body=$(document.body);
                    var loadedCount=0;
                    if(ifrs.length<pages.length){
                        for(var i=0;i<pages.length;i++){
                            var ifr=$('<iframe style="display:none" />').appendTo($body);
                            ifrs.push(ifr[0]);
                            (function(cur){
                                ifrs[cur].onload=function(e){
                                    loadedCount++;
                                    ////debugger;
                                    //var url = arguments[0].target.contentWindow.location.href;
                                    if (e.target.contentDocument.getElementById('remember')) {//报错跳回了登陆页
                                        //debugger;
                                        errorPages.push(this.src);
                                    }
                                    //debugger;
                                    if(loadedCount===pages.length){
                                        if(errorPages.length>0){
                                            //console.info(errorPages);
                                            alert('以下页面有js错误:'+JSON.stringify(errorPages));
                                        }else{
                                            alert("恭喜！"+pages.length+"个页面无js错误");
                                        }
                                    }
                                };
                            })(i);
                                // debugger;
                        }
                    }
                    for(var i=0;i<pages.length;i++){
                        var url =pages[i]+ (pages[i].indexOf('?') > -1 ? ard : rd);
                        $(ifrs[i]).attr('src', url);
                    }
                });

            });
        </script>
    </head>
    <body>
        <!-- <iframe id='errorPageIFrame' name='errorPageIFrame'></iframe> -->
        <input type="button" id="idBtn1" value="开始测试">
    </body>
</html>